<a href='https://github.com/angular/angular.js/edit/v1.4.x/src/ngCookies/cookies.js?message=docs($cookies)%3A%20describe%20your%20change...#L55' class='improve-docs btn btn-primary'><i class="glyphicon glyphicon-edit">&nbsp;</i>Improve this Doc</a>



<a href='https://github.com/angular/angular.js/tree/v1.4.7/src/ngCookies/cookies.js#L55' class='view-source pull-right btn btn-primary'>
  <i class="glyphicon glyphicon-zoom-in">&nbsp;</i>View Source
</a>


<header class="api-profile-header">
  <h1 class="api-profile-header-heading">$cookies</h1>
  <ol class="api-profile-header-structure naked-list step-list">
    
  <li>
    <a href="api/ngCookies/provider/$cookiesProvider">- $cookiesProvider</a>
  </li>

    <li>
      - service in module <a href="api/ngCookies">ngCookies</a>
    </li>
  </ol>
</header>



<div class="api-profile-description">
  <p>Provides read/write access to browser&#39;s cookies.</p>
<div class="alert alert-info">
Up until Angular 1.3, <code>$cookies</code> exposed properties that represented the
current browser cookie values. In version 1.4, this behavior has changed, and
<code>$cookies</code> now provides a standard api of getters, setters etc.
</div>

<p>Requires the <a href="api/ngCookies"><code>ngCookies</code></a> module to be installed.</p>

</div>




<div>
  

    

  

  
<h2>Methods</h2>
<ul class="methods">
  <li id="get">
    <h3><p><code>get(key);</code></p>

</h3>
    <div><p>Returns the value of given cookie key</p>
</div>

    
    <h4>Parameters</h4>
    
<table class="variables-matrix input-arguments">
  <thead>
    <tr>
      <th>Param</th>
      <th>Type</th>
      <th>Details</th>
    </tr>
  </thead>
  <tbody>
    
    <tr>
      <td>
        key
        
        
      </td>
      <td>
        <a href="" class="label type-hint type-hint-string">string</a>
      </td>
      <td>
        <p>Id to use for lookup.</p>

        
      </td>
    </tr>
    
  </tbody>
</table>

    

    
    
    
    <h4>Returns</h4>
    <table class="variables-matrix return-arguments">
  <tr>
    <td><a href="" class="label type-hint type-hint-string">string</a></td>
    <td><p>Raw cookie value.</p>
</td>
  </tr>
</table>
    

  </li>
  
  <li id="getObject">
    <h3><p><code>getObject(key);</code></p>

</h3>
    <div><p>Returns the deserialized value of given cookie key</p>
</div>

    
    <h4>Parameters</h4>
    
<table class="variables-matrix input-arguments">
  <thead>
    <tr>
      <th>Param</th>
      <th>Type</th>
      <th>Details</th>
    </tr>
  </thead>
  <tbody>
    
    <tr>
      <td>
        key
        
        
      </td>
      <td>
        <a href="" class="label type-hint type-hint-string">string</a>
      </td>
      <td>
        <p>Id to use for lookup.</p>

        
      </td>
    </tr>
    
  </tbody>
</table>

    

    
    
    
    <h4>Returns</h4>
    <table class="variables-matrix return-arguments">
  <tr>
    <td><a href="" class="label type-hint type-hint-object">Object</a></td>
    <td><p>Deserialized cookie value.</p>
</td>
  </tr>
</table>
    

  </li>
  
  <li id="getAll">
    <h3><p><code>getAll();</code></p>

</h3>
    <div><p>Returns a key value object with all the cookies</p>
</div>

    

    
    
    
    <h4>Returns</h4>
    <table class="variables-matrix return-arguments">
  <tr>
    <td><a href="" class="label type-hint type-hint-object">Object</a></td>
    <td><p>All cookies</p>
</td>
  </tr>
</table>
    

  </li>
  
  <li id="put">
    <h3><p><code>put(key, value, [options]);</code></p>

</h3>
    <div><p>Sets a value for given cookie key</p>
</div>

    
    <h4>Parameters</h4>
    
<table class="variables-matrix input-arguments">
  <thead>
    <tr>
      <th>Param</th>
      <th>Type</th>
      <th>Details</th>
    </tr>
  </thead>
  <tbody>
    
    <tr>
      <td>
        key
        
        
      </td>
      <td>
        <a href="" class="label type-hint type-hint-string">string</a>
      </td>
      <td>
        <p>Id for the <code>value</code>.</p>

        
      </td>
    </tr>
    
    <tr>
      <td>
        value
        
        
      </td>
      <td>
        <a href="" class="label type-hint type-hint-string">string</a>
      </td>
      <td>
        <p>Raw value to be stored.</p>

        
      </td>
    </tr>
    
    <tr>
      <td>
        options
        
        <div><em>(optional)</em></div>
      </td>
      <td>
        <a href="" class="label type-hint type-hint-object">Object</a>
      </td>
      <td>
        <p>Options object.
   See <a href="api/ngCookies/provider/$cookiesProvider#defaults">$cookiesProvider.defaults</a></p>

        
      </td>
    </tr>
    
  </tbody>
</table>

    

    
    
    

  </li>
  
  <li id="putObject">
    <h3><p><code>putObject(key, value, [options]);</code></p>

</h3>
    <div><p>Serializes and sets a value for given cookie key</p>
</div>

    
    <h4>Parameters</h4>
    
<table class="variables-matrix input-arguments">
  <thead>
    <tr>
      <th>Param</th>
      <th>Type</th>
      <th>Details</th>
    </tr>
  </thead>
  <tbody>
    
    <tr>
      <td>
        key
        
        
      </td>
      <td>
        <a href="" class="label type-hint type-hint-string">string</a>
      </td>
      <td>
        <p>Id for the <code>value</code>.</p>

        
      </td>
    </tr>
    
    <tr>
      <td>
        value
        
        
      </td>
      <td>
        <a href="" class="label type-hint type-hint-object">Object</a>
      </td>
      <td>
        <p>Value to be stored.</p>

        
      </td>
    </tr>
    
    <tr>
      <td>
        options
        
        <div><em>(optional)</em></div>
      </td>
      <td>
        <a href="" class="label type-hint type-hint-object">Object</a>
      </td>
      <td>
        <p>Options object.
   See <a href="api/ngCookies/provider/$cookiesProvider#defaults">$cookiesProvider.defaults</a></p>

        
      </td>
    </tr>
    
  </tbody>
</table>

    

    
    
    

  </li>
  
  <li id="remove">
    <h3><p><code>remove(key, [options]);</code></p>

</h3>
    <div><p>Remove given cookie</p>
</div>

    
    <h4>Parameters</h4>
    
<table class="variables-matrix input-arguments">
  <thead>
    <tr>
      <th>Param</th>
      <th>Type</th>
      <th>Details</th>
    </tr>
  </thead>
  <tbody>
    
    <tr>
      <td>
        key
        
        
      </td>
      <td>
        <a href="" class="label type-hint type-hint-string">string</a>
      </td>
      <td>
        <p>Id of the key-value pair to delete.</p>

        
      </td>
    </tr>
    
    <tr>
      <td>
        options
        
        <div><em>(optional)</em></div>
      </td>
      <td>
        <a href="" class="label type-hint type-hint-object">Object</a>
      </td>
      <td>
        <p>Options object.
   See <a href="api/ngCookies/provider/$cookiesProvider#defaults">$cookiesProvider.defaults</a></p>

        
      </td>
    </tr>
    
  </tbody>
</table>

    

    
    
    

  </li>
  </ul>
  
  



  
  <h2 id="example">Example</h2><pre><code class="lang-js">angular.module(&#39;cookiesExample&#39;, [&#39;ngCookies&#39;])
.controller(&#39;ExampleController&#39;, [&#39;$cookies&#39;, function($cookies) {
  // Retrieving a cookie
  var favoriteCookie = $cookies.get(&#39;myFavorite&#39;);
  // Setting a cookie
  $cookies.put(&#39;myFavorite&#39;, &#39;oatmeal&#39;);
}]);
</code></pre>

</div>


